using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SBPweb.Presentation.Windows.Forms.Controls
{
	public partial class LayoutNamingForm : SBPweb.Controls.Windows.Common.Form
	{
		public string LayoutName
		{
			get
			{
				return tbNameLayout.Text;
			}
			set
			{
				tbNameLayout.Text = value;
			}
		}

		public LayoutNamingForm()
		{
			InitializeComponent();
		}

		void tbName_TextChanged(object sender, EventArgs e)
		{
			if (tbNameLayout.Text.Length > 0)
				btnOK.Enabled = true;
			else
				btnOK.Enabled = false;
		}

		void btOk_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.OK;
			Close();
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.Cancel;
			Close();
		}

		public string Execute(string oldName)
		{
			oldName = oldName == null ? string.Empty : oldName;
			tbNameLayout.Text = oldName;
			if (this.ShowDialog() == DialogResult.OK)
			{
				if (oldName != tbNameLayout.Text && !string.IsNullOrEmpty(tbNameLayout.Text))
				{
					return tbNameLayout.Text;
				}
			}
			return null;
		}

		public string Execute()
		{
			return Execute(null);
		}

	}
}